import { BrowserWindow } from 'electron';
import path from 'path'

const winURL = process.env.NODE_ENV === 'development'
    ? `http://localhost:9080/`
    : `file://${__dirname}/index.html`;

export default () => {
    let win = new BrowserWindow({
        title: 'Requester',
        height: 800,
        width: 1280,
        minWidth: 1280,
        minHeight: 800,
        useContentSize: false,
        frame: false,
        show: false,
        icon: path.join(__static, 'logo-256x256.png'),
        webPreferences: {
            nodeIntegration: true,
            webSecurity: false
        }
    })
    win.once('ready-to-show', () => {
        win.show();
    });
    win.loadURL(winURL)
    win.on('close', function (e) {
        e.preventDefault();
        win.hide();
    });
    win.webContents.on('did-finish-load', function () {
        win.webContents.send('routerView', JSON.stringify({
            url: '/service',
        }));
    });
    return win;
};

